try:
    import gc, lcd, image, sys, uos
    lcd.init()
    lcd.clear(color=(255,0,0))

    loading = image.Image(size=(lcd.width(), lcd.height())) # 用来显示当前固件版本
    loading.draw_rectangle((0, 0, lcd.width(), lcd.height()), fill=True, color=(255, 0, 0))
    info = "Welcome to MaixPy"
    loading.draw_string(int(lcd.width()//2 - len(info) * 5), (lcd.height())//4, info, color=(255, 255, 255), scale=2, mono_space=0)
    v = sys.implementation.version
    vers = 'V{}.{}.{} : maixpy.sipeed.com'.format(v[0],v[1],v[2])
    loading.draw_string(int(lcd.width()//2 - len(info) * 6), (lcd.height())//3 + 20, vers, color=(255, 255, 255), scale=1, mono_space=1)
    lcd.display(loading)
    tf = None
    try:
        uos.listdir("/sd") # 测试能否读取 sd 卡
    except Exception as e:
        tf ="SDcard not mount,use flash!"
        loading.draw_string(int(lcd.width()//2 - len(info) * 7), (lcd.height())//2 + 10, tf, color=(255, 255, 255), scale=1, mono_space=1)
    if not tf:
        tf ="SDcard is mount,use SD!"
        loading.draw_string(int(lcd.width()//2 - len(info) * 6), (lcd.height())//2 + 10, tf, color=(255, 255, 255), scale=1, mono_space=1)
    lcd.display(loading)
    del loading, v, info, vers
    gc.collect()

    if tf:
        img = image.Image("/sd/images/crazing_177.jpg", copy_to_fb=True)
        lcd.display(img)
        img = image.Image("/sd/images/patches_254.jpg", copy_to_fb=True)
        lcd.display(img)
        print(img)
        for i in uos.listdir("/sd/images"):  # 遍历图像
            print(i)
            img = image.Image("/sd/images/"+i, copy_to_fb=True)   # 从 sd 卡读取 jpg
            lcd.display(img)
    gc.collect()

finally:
    gc.collect()
